{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "using ReinforcementLearningAnIntroduction"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "using StatsBase, Plots"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-1.0:0.1:1.0"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "const N = 21\n",
    "\n",
    "const true_values = -1:0.1:1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "Base.@kwdef struct RecordRMS <: AbstractHook\n",
    "    rms::Vector{Float64}=[]\n",
    "end\n",
    "\n",
    "(h::RecordRMS)(::PostEpisodeStage, agent, env, obs) = push!(h.rms, sqrt(mean((agent.policy.learner.approximator.table[2:end-1] - true_values[2:end-1]).^2)))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "records (generic function with 2 methods)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "function create_agent_env(α, λ)\n",
    "    env = RandomWalkEnv(N=21)\n",
    "    ns, na =  length(get_observation_space(env)),  length(get_action_space(env))\n",
    "    agent = Agent(\n",
    "        policy=VBasedPolicy(\n",
    "            learner=TDλReturnLearner(\n",
    "                approximator=TabularApproximator(n_state=ns),\n",
    "                γ=1.0,\n",
    "                α=α,\n",
    "                λ=λ\n",
    "            ),\n",
    "            mapping = (obs, V) -> begin\n",
    "                values = zeros(na)\n",
    "                values[rand(1:na)] = 1.0\n",
    "                values\n",
    "            end\n",
    "        ),\n",
    "        trajectory=EpisodicCompactSARTSATrajectory()\n",
    "    )\n",
    "    agent, env\n",
    "end\n",
    "\n",
    "function records(α, λ, nruns=10)\n",
    "    rms = []\n",
    "    for _ in 1:nruns\n",
    "        hook = RecordRMS()\n",
    "        run(create_agent_env(α, λ)..., StopAfterEpisode(10, is_show_progress=false),hook)\n",
    "        push!(rms, mean(hook.rms))\n",
    "    end\n",
    "    mean(rms)\n",
    "end"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 2400 1600\">\n",
       "<defs>\n",
       "  <clipPath id=\"clip0300\">\n",
       "    <rect x=\"0\" y=\"0\" width=\"2400\" height=\"1600\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<path clip-path=\"url(#clip0300)\" d=\"\n",
       "M0 1600 L2400 1600 L2400 0 L0 0  Z\n",
       "  \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
       "<defs>\n",
       "  <clipPath id=\"clip0301\">\n",
       "    <rect x=\"480\" y=\"0\" width=\"1681\" height=\"1600\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<path clip-path=\"url(#clip0300)\" d=\"\n",
       "M180.66 1487.47 L2352.76 1487.47 L2352.76 47.2441 L180.66 47.2441  Z\n",
       "  \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
       "<defs>\n",
       "  <clipPath id=\"clip0302\">\n",
       "    <rect x=\"180\" y=\"47\" width=\"2173\" height=\"1441\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  242.135,1487.47 242.135,47.2441 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  754.421,1487.47 754.421,47.2441 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  1266.71,1487.47 1266.71,47.2441 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  1778.99,1487.47 1778.99,47.2441 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  2291.28,1487.47 2291.28,47.2441 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  180.66,1487.47 2352.76,1487.47 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  180.66,1247.44 2352.76,1247.44 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  180.66,1007.4 2352.76,1007.4 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  180.66,767.359 2352.76,767.359 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  180.66,527.321 2352.76,527.321 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  180.66,287.283 2352.76,287.283 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  180.66,47.2441 2352.76,47.2441 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  180.66,1487.47 2352.76,1487.47 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  180.66,1487.47 180.66,47.2441 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  242.135,1487.47 242.135,1470.19 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  754.421,1487.47 754.421,1470.19 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1266.71,1487.47 1266.71,1470.19 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1778.99,1487.47 1778.99,1470.19 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  2291.28,1487.47 2291.28,1470.19 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  180.66,1487.47 206.725,1487.47 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  180.66,1247.44 206.725,1247.44 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  180.66,1007.4 206.725,1007.4 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  180.66,767.359 206.725,767.359 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  180.66,527.321 206.725,527.321 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  180.66,287.283 206.725,287.283 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  180.66,47.2441 206.725,47.2441 \n",
       "  \"/>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 242.135, 1541.47)\" x=\"242.135\" y=\"1541.47\">0.00</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 754.421, 1541.47)\" x=\"754.421\" y=\"1541.47\">0.25</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 1266.71, 1541.47)\" x=\"1266.71\" y=\"1541.47\">0.50</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 1778.99, 1541.47)\" x=\"1778.99\" y=\"1541.47\">0.75</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 2291.28, 1541.47)\" x=\"2291.28\" y=\"1541.47\">1.00</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 156.66, 1504.97)\" x=\"156.66\" y=\"1504.97\">0.25</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 156.66, 1264.94)\" x=\"156.66\" y=\"1264.94\">0.30</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 156.66, 1024.9)\" x=\"156.66\" y=\"1024.9\">0.35</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 156.66, 784.859)\" x=\"156.66\" y=\"784.859\">0.40</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 156.66, 544.821)\" x=\"156.66\" y=\"544.821\">0.45</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 156.66, 304.783)\" x=\"156.66\" y=\"304.783\">0.50</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 156.66, 64.7441)\" x=\"156.66\" y=\"64.7441\">0.55</text>\n",
       "</g>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#009af9; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  242.135,58.1776 447.049,258.227 651.964,430.337 856.879,568.265 1061.79,707.717 1266.71,831.909 1471.62,956.28 1676.54,1015.78 1881.45,1033.23 2086.37,976.002 \n",
       "  2291.28,845.688 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#e26f46; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  242.135,58.1776 447.049,378.432 651.964,641.846 856.879,864.662 1061.79,1053.79 1266.71,1235.64 1471.62,1345.25 1676.54,1304.78 1881.45,1344.51 2086.37,1105.97 \n",
       "  2291.28,1292.15 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#3da44d; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  242.135,58.1776 447.049,761.761 651.964,1236.78 856.879,1499.34 1061.79,1402.98 1266.71,1357.76 1471.62,1238.36 1676.54,1071.49 1881.45,1063.61 2086.37,979.458 \n",
       "  2291.28,1003.63 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#c271d2; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  242.135,58.1776 447.049,1019.19 651.964,1233.65 856.879,1277.91 1061.79,1205.87 1266.71,1125.31 1471.62,780.877 1676.54,877.884 1881.45,763.631 2086.37,561.852 \n",
       "  2291.28,538.565 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#ac8d18; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  242.135,58.1776 447.049,1153.46 651.964,1205.16 856.879,944.507 1061.79,651.313 1266.71,725.245 1471.62,666.826 1676.54,319.95 1881.45,429.635 2086.37,224.186 \n",
       "  2291.28,-127.119 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#00a9ad; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  242.135,58.1776 344.592,890.556 447.049,831.45 549.507,802.223 651.964,788.986 754.421,752.224 856.879,495.236 959.336,317.604 1061.79,278.335 1164.25,100.658 \n",
       "  1266.71,35.3234 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#ed5d92; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  242.135,58.1776 283.118,502.576 324.101,633.492 365.084,390.375 406.066,784.148 447.049,508.015 488.032,221.914 529.015,328.352 569.998,397.839 610.981,-9.37927 \n",
       "  651.964,205.123 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0302)\" style=\"stroke:#c68125; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  242.135,58.1776 262.626,281.757 283.118,346.765 303.609,403.418 324.101,181.454 344.592,334.149 365.084,152.9 385.575,29.4155 406.066,-61.4774 426.558,-40.458 \n",
       "  447.049,19.2942 \n",
       "  \"/>\n",
       "<path clip-path=\"url(#clip0300)\" d=\"\n",
       "M1707.62 675.084 L2280.76 675.084 L2280.76 130.764 L1707.62 130.764  Z\n",
       "  \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1707.62,675.084 2280.76,675.084 2280.76,130.764 1707.62,130.764 1707.62,675.084 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#009af9; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1731.62,191.244 1875.62,191.244 \n",
       "  \"/>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:start;\" transform=\"rotate(0, 1899.62, 208.744)\" x=\"1899.62\" y=\"208.744\">lambda = 0.0</text>\n",
       "</g>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#e26f46; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1731.62,251.724 1875.62,251.724 \n",
       "  \"/>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:start;\" transform=\"rotate(0, 1899.62, 269.224)\" x=\"1899.62\" y=\"269.224\">lambda = 0.4</text>\n",
       "</g>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#3da44d; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1731.62,312.204 1875.62,312.204 \n",
       "  \"/>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:start;\" transform=\"rotate(0, 1899.62, 329.704)\" x=\"1899.62\" y=\"329.704\">lambda = 0.8</text>\n",
       "</g>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#c271d2; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1731.62,372.684 1875.62,372.684 \n",
       "  \"/>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:start;\" transform=\"rotate(0, 1899.62, 390.184)\" x=\"1899.62\" y=\"390.184\">lambda = 0.9</text>\n",
       "</g>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#ac8d18; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1731.62,433.164 1875.62,433.164 \n",
       "  \"/>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:start;\" transform=\"rotate(0, 1899.62, 450.664)\" x=\"1899.62\" y=\"450.664\">lambda = 0.95</text>\n",
       "</g>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#00a9ad; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1731.62,493.644 1875.62,493.644 \n",
       "  \"/>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:start;\" transform=\"rotate(0, 1899.62, 511.144)\" x=\"1899.62\" y=\"511.144\">lambda = 0.975</text>\n",
       "</g>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#ed5d92; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1731.62,554.124 1875.62,554.124 \n",
       "  \"/>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:start;\" transform=\"rotate(0, 1899.62, 571.624)\" x=\"1899.62\" y=\"571.624\">lambda = 0.99</text>\n",
       "</g>\n",
       "<polyline clip-path=\"url(#clip0300)\" style=\"stroke:#c68125; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1731.62,614.604 1875.62,614.604 \n",
       "  \"/>\n",
       "<g clip-path=\"url(#clip0300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:start;\" transform=\"rotate(0, 1899.62, 632.104)\" x=\"1899.62\" y=\"632.104\">lambda = 1.0</text>\n",
       "</g>\n",
       "</svg>\n"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "As = [0:0.1:1, 0:0.1:1, 0:0.1:1, 0:0.1:1, 0:0.1:1, 0:0.05:0.5, 0:0.02:0.2, 0:0.01:0.1]\n",
    "Λ = [0., 0.4, .8, 0.9, 0.95, 0.975, 0.99, 1.]\n",
    "p = plot(legend=:topright)\n",
    "for (A, λ) in zip(As, Λ)\n",
    "    plot!(p, A, [records(α, λ) for α in A], label=\"lambda = $λ\")\n",
    "end\n",
    "ylims!(p, (0.25, 0.55))\n",
    "p"
   ]
  }
 ],
 "metadata": {
  "@webio": {
   "lastCommId": null,
   "lastKernelId": null
  },
  "kernelspec": {
   "display_name": "Julia 1.3.0",
   "language": "julia",
   "name": "julia-1.3"
  },
  "language_info": {
   "file_extension": ".jl",
   "mimetype": "application/julia",
   "name": "julia",
   "version": "1.3.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
